Ext.define('Jason.view.NewMainViewModel', {
    extend: 'Ext.app.ViewModel',
    alias: 'viewmodel.newMainViewModel',
    data:{
        showLogo: localStorage.getItem('isShowLogo')==='true'?true:false,
        topToolbarBkc: localStorage.getItem('topToolbarBkc') || '#3479fd',
        isTreeMenu: localStorage.getItem('isTreeMenu')==='true'?true:false,
        isToolbarMenu: localStorage.getItem('isToolbarMenu')==='true'?true:false,
        userName: cfg.sub.accountInfo.realname || '暂无人员登录'
    },
    constructor: function(){
        Ext.log('MainModel constructor');
        var me = this;
        localStorage.setItem('isToolbarMenu',true);
        localStorage.setItem('pageStyle','advanced');
        me.callParent(arguments);
        if (session.get('loginState') === undefined || session.get('loginState') === false) {
            me.data.isTreeMenu = false;
        }
        me.notify();
    },
    initUserLocalSetter:function(){
        var me =this;
        me.set('isTreeMenu',localStorage.getItem('isTreeMenu')==='true'?true:false);
        me.set('isToolbarMenu',localStorage.getItem('isToolbarMenu')==='true'?true:false);
    },
    stores:{
        NavigationTree:{
            type : 'NavigationTree'
        }
    },
    formulas: {
        userName: function () {
            try {
                return cfg.sub.accountInfo.realname;
            } catch (e) {
                return '暂无人员登录';
            }
        },
        loginedProfile: function () {
            return '<div class="back-sky-layout-header-nav-user-info">' +
                '	<div class="back-sky-layout-header-nav-user-name">' +
                (session.get('realname') || '暂未登录') +
                '	</div> ' +
                '	<div class="back-sky-layout-header-nav-user-category">' +
                (session.get('dept') || '暂未登录') +
                '	</div>' +
                '</div>';
        },
        themeDefault: function(){ //默认主体布局
        	return [{
                width: 200, xtype: 'container', border: true,
                itemId: 'treePanel', height: '100%',
                items: [{
                    itemId: 'dynamicTree', flex: 1,
                    listeners: { selectionchange: 'onMenuSelectChangeByNavel' },
                    expanderFirst: false,
                    expanderOnly: false,
                    //singleExpand: true,
                    xtype: 'custom_treelist',
                    ui: 'navigation-white',
                    reference: 'dynamicTree',
                    store: null
                }],
                ui: 'light',
                autoScroll: true,
                hidden: true
            }, {
                xtype: 'card-layout-panel',
                reference: 'appBody',
                flex: 1
            }]
        }
    }
});